﻿<Gadgets:GadgetBase x:Class="Epi.WPF.Dashboard.Gadgets.Analysis.CrosstabControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Gadgets="clr-namespace:Epi.WPF.Dashboard.Gadgets"
    xmlns:Dashboard="clr-namespace:Epi.WPF.Dashboard"
    xmlns:Controls="clr-namespace:Epi.WPF.Dashboard.Controls"
    Style="{DynamicResource gadgetBaseStyle}">
    <Gadgets:GadgetBase.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../../ResourceDictionary.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Gadgets:GadgetBase.Resources>
    <Grid>
        <!--<Controls:ShadowRectangle x:Name="rectangleShadow"></Controls:ShadowRectangle>-->
        <Border Name="borderAll" Style="{DynamicResource mainGadgetBorder}" >
            <Border.ContextMenu>
                <ContextMenu x:Name="gadgetContextMenu">
                    <MenuItem x:Name="mnuCopy" Header="Copy data to clipboard"/>
                    <MenuItem x:Name="mnuSendDataToHTML" Header="Send data to web browser">
                        <MenuItem.Icon>
                            <Image Source="../../Images/saveHTML.png" />
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem x:Name="mnuSendDataToExcel" Header="Send data to Excel" />
                    <Separator/>
                    <MenuItem x:Name="mnuSendToBack" Header="Send gadget to back"/>                    
                    <MenuItem x:Name="mnuClose" Header="Close this gadget"/>
                </ContextMenu>
            </Border.ContextMenu>

            <Grid x:Name="grdMain">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="6" />
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="6" />
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="6" />
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="*"></RowDefinition>
                </Grid.RowDefinitions>
                <Controls:GadgetHeaderPanel x:Name="headerPanel" Grid.Row="0" Text="Crosstabulation (MxN, 2x2)" />
                <Controls:GadgetMessagePanel Margin="5" x:Name="messagePanel" Grid.Row="2" Text="" />
                <Controls:GadgetDescriptionPanel Grid.Row="4" PanelMode="Collapsed" x:Name="descriptionPanel"></Controls:GadgetDescriptionPanel>
                <!--<TextBlock Grid.Row="6" x:Name="txtFilterString" Style="{DynamicResource filterStringText}" Visibility="Collapsed" />-->

                <Controls:GadgetInfoPanel Grid.Row="4" Visibility="Collapsed" Margin="5" x:Name="infoPanel"></Controls:GadgetInfoPanel>
                
                <StackPanel Grid.Row="7" x:Name="panelMain" HorizontalAlignment="Left" VerticalAlignment="Top"></StackPanel>
                <Controls:GadgetWaitPanel x:Name="waitPanel" Visibility="Collapsed" Grid.Row="1" Grid.RowSpan="6" HorizontalAlignment="Center" Style="{DynamicResource gadgetWaitPanelStyle}" />

                <StackPanel Grid.Row="1" Grid.RowSpan="7" Margin="00,-15,-10,0"  HorizontalAlignment="Right" VerticalAlignment="Top" >
                    <Grid x:Name="ConfigGrid" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,15,10,0" >
                        <Rectangle Style="{DynamicResource rectangleConfigOuter}" />
                        <Rectangle Style="{DynamicResource rectangleConfigInner}" />

                        <Path x:Name="pathTriangle" 
                              Margin="0,-2,68,0"
                              Data="M 5 0 L 10 10 0 10 Z" Fill="{DynamicResource gadgetBackgroundBrush}" IsHitTestVisible="False" HorizontalAlignment="Right" VerticalAlignment="Top" Height="7" />

                        <StackPanel Orientation="Vertical" Margin="25, 10, 25, 25" HorizontalAlignment="Center" VerticalAlignment="Top" >
                            <TextBlock x:Name="ConfigExpandedTitle" HorizontalAlignment="Center" TextAlignment="Center" Text="Crosstabulation Properties" Margin="5" FontWeight="Bold" />
                    <TextBlock x:Name="tblockExposureField" HorizontalAlignment="Left" TextAlignment="Center" Text="Exposure:" Margin="0,5,0,0"  />
                            <ComboBox x:Name="cbxExposureField" Width="Auto" HorizontalAlignment="Stretch" SelectedIndex="0" />
                            <TextBlock x:Name="tblockOutcomeField" HorizontalAlignment="Left" TextAlignment="Center" Text="Outcome:" Margin="0,5,0,0"  />
                            <ComboBox x:Name="cbxOutcomeField" Width="Auto" HorizontalAlignment="Stretch" SelectedIndex="0" />

                            <Expander Margin="0, 5, 0, 0" x:Name="expanderAdvancedOptions" Header="Advanced options">
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                                        <ColumnDefinition Width="10"></ColumnDefinition>
                                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                                    </Grid.ColumnDefinitions>

                                    <StackPanel x:Name="panelAdvanced" Grid.Column="0">
                                        <TextBlock x:Name="tblockWeightVariable" HorizontalAlignment="Left" TextAlignment="Center" Text="Weight:" Margin="0,5,0,0"  />
                                        <ComboBox x:Name="cbxFieldWeight" Width="Auto" HorizontalAlignment="Stretch" SelectedIndex="0" />
                                        <TextBlock x:Name="tblockStratifyBy" HorizontalAlignment="Left" TextAlignment="Center" Text="Stratify by:" Margin="0,5,0,0"  />
                                        <!--<ComboBox x:Name="cbxFieldStrata" Width="140" HorizontalAlignment="Left" SelectedIndex="0" />-->
                                        <ListBox x:Name="lbxFieldStrata" VirtualizingStackPanel.VirtualizationMode="Recycling" Width="180" Height="120" SelectionMode="Extended" HorizontalAlignment="Left" />

                                        <!--<TextBlock HorizontalAlignment="Left" TextAlignment="Center" Text="Max rows to display:" Margin="0,5,0,0"  />
                                    <TextBox x:Name="txtMaxRows" Width="60" HorizontalAlignment="Left" Text="200" Margin="0, 0, 0, 10" PreviewTextInput="txtMaxColumns_PreviewTextInput"></TextBox>

                                    <TextBlock HorizontalAlignment="Left" TextAlignment="Center" Text="Max columns to display:" Margin="0,5,0,0"  />
                                    <TextBox x:Name="txtMaxColumns" Width="60" HorizontalAlignment="Left" Text="20" Margin="0, 0, 0, 10" PreviewTextInput="txtMaxColumns_PreviewTextInput"></TextBox>-->                                        
                                    </StackPanel>

                                    <StackPanel x:Name="panelAdvanced2" Grid.Column="2">
                                        <CheckBox x:Name="checkboxAllValues" Margin="0,5,0,0" Content="Display all list values"  HorizontalAlignment="Left" IsEnabled="True"/>
                                        <CheckBox x:Name="checkboxCommentLegalLabels" Margin="0,5,0,0" Content="Display list labels"  HorizontalAlignment="Left" IsEnabled="True"/>
                                        <CheckBox x:Name="checkboxIncludeMissing" Margin="0,5,0,0" Content="Include missing values" HorizontalAlignment="Left" IsChecked="False" />
                                        <CheckBox x:Name="checkboxOutcomeContinuous" Margin="0,5,0,0" Content="Outcome is continuous"  HorizontalAlignment="Left" IsEnabled="True" />
                                        <CheckBox x:Name="checkboxRowColPercents" Margin="0,5,0,0" Content="Row / column percents"  HorizontalAlignment="Left" IsEnabled="True" IsChecked="True" />
                                        <CheckBox x:Name="checkboxSmartTable" Margin="0,5,0,0" Content="Smart 2x2 table"  HorizontalAlignment="Left" IsEnabled="True" IsChecked="True" />
                                        <CheckBox x:Name="checkboxHorizontal" Margin="0,5,0,0" Content="Display stratas horizontally"  HorizontalAlignment="Left" Visibility="Collapsed" IsEnabled="True" IsChecked="False" />
                                        <CheckBox x:Name="checkboxStrataSummaryOnly" Margin="0,5,0,0" Content="Show strata summary only"  HorizontalAlignment="Left" IsEnabled="True" IsChecked="False" />

                                        <TextBlock x:Name="tblockMaxColumnLength" HorizontalAlignment="Left" TextAlignment="Center" Text="Max column name length:" Margin="0,5,0,0"  />
                                        <TextBox x:Name="txtMaxColumnLength" Width="60" HorizontalAlignment="Left" Text="24" Margin="0, 0, 0, 10" PreviewTextInput="txtMaxColumns_PreviewTextInput"></TextBox>                                                                                                                         
                                    </StackPanel>

                                </Grid>
                                
                            </Expander>

                            <Button x:Name="btnRun" Content="Run" Margin="0,20,0,0" Click="btnRun_Click" />
                            
                        </StackPanel>                            
            </Grid>
        </StackPanel>                
            </Grid>
        </Border>        
    </Grid>
</Gadgets:GadgetBase>
